Skip to content

feat: authorize tags and taxonomies endpoints via openedx-authz when …#38292

Draft
wgu-taylor-payne wants to merge 1 commit intoopenedx:masterfrom
WGU-Open-edX:tpayne/authz-for-taxonomies
Draft

feat: authorize tags and taxonomies endpoints via openedx-authz when …#38292
wgu-taylor-payne wants to merge 1 commit intoopenedx:masterfrom
WGU-Open-edX:tpayne/authz-for-taxonomies

Conversation

@wgu-taylor-payne
Copy link
Copy Markdown
Contributor

@wgu-taylor-payne wgu-taylor-payne commented Apr 7, 2026

Description

Adds courses.manage_tags permission check via openedx-authz to the course-scoped content tagging endpoints, behind the existing AUTHZ_COURSE_AUTHORING_FLAG feature flag. When the flag is off, behavior is unchanged — all endpoints use the existing legacy django-rules permission checks.

Taxonomy management endpoints are not course-scoped (/taxonomies/ CRUD, import, export, manage orgs) and will not be included in this PR. Those endpoints will be addressed another time.

What this PR does:

  • PUT /object_tags/{object_id}/ — enforces courses.manage_tags when the flag is enabled for the course. Extracts the course key from any content key type (course, block, unit, collection, container) via get_context_key_from_key_string, so tagging at any level within a flagged course goes through authz. Library content is unaffected (falls through to legacy).

  • GET /object_tags/{object_id}/ — patches can_tag_object in the response to reflect the authz permission when the flag is enabled. This ensures the frontend correctly shows/hides the "Add tags" button without any frontend changes.

  • GET /object_tags/{context_id}/export/ — already had authz via has_view_object_tags_access (checks courses.export_tags). No changes needed.

Endpoint → permission mapping:

Endpoint Permission Flag scope
PUT /object_tags/{object_id}/ courses.manage_tags per-course
GET /object_tags/{object_id}/ (read — legacy rules + can_tag_object patched) per-course
GET /object_tags/{context_id}/export/ courses.export_tags (existing, unchanged) per-course

Roles and permissions (from Casbin policy):

Role manage_tags export_tags
course_admin
course_staff
course_editor
course_auditor

Supporting information

Testing instructions

Flag OFF (legacy behavior unchanged):

  1. Ensure authz.enable_course_authoring waffle flag is inactive
  2. As a course staff user, verify tagging content objects works as before
  3. Verify GET /object_tags/{course_id}/ returns correct can_tag_object values

Flag ON per-course:

  1. Django Admin → Waffle Flag Course Overrides → authz.enable_course_authoring for a specific course → Force On
  2. As a user with course_staff authz role for that course: PUT /object_tags/{course_id}/ should succeed
  3. As a user with course_auditor role: should return 403
  4. As a user without any role: should return 403
  5. GET /object_tags/{course_id}/ should return can_tag_object: true for course_staff/course_editor/course_admin, false for course_auditor and unauthorized
  6. For a different course without the override: should fall through to legacy checks

Other information

  • Query count tests updated: +2 queries for course-scoped requests (waffle flag course/org override lookups). Non-course content (libraries, collections) unaffected.
  • Co-authored with Kiro — AI-assisted implementation and testing.

@wgu-taylor-payne wgu-taylor-payne self-assigned this Apr 7, 2026
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Apr 7, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Apr 7, 2026

Thanks for the pull request, @wgu-taylor-payne!

This repository is currently maintained by @openedx/wg-maintenance-openedx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation bot moved this to Needs Triage in Contributions Apr 7, 2026
@wgu-taylor-payne wgu-taylor-payne marked this pull request as draft April 7, 2026 01:42
@wgu-taylor-payne wgu-taylor-payne force-pushed the tpayne/authz-for-taxonomies branch 2 times, most recently from d1ae95c to c26f972 Compare April 7, 2026 16:30
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Apr 8, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Apr 8, 2026
@rodmgwgu
Copy link
Copy Markdown
Contributor

rodmgwgu commented Apr 9, 2026

@wgu-taylor-payne we discussed this in the Weekly meeting and the decision is that for M1 we will only focus on implementing the courses.manage_tags permission on course-related endpoints.

So no taxonomies-related changes for now.

@wgu-taylor-payne wgu-taylor-payne force-pushed the tpayne/authz-for-taxonomies branch 3 times, most recently from 7ef84c8 to 93083cc Compare April 10, 2026 18:11
…bled

Add courses.manage_tags permission check on PUT /object_tags/{course_id}/
behind the AUTHZ_COURSE_AUTHORING_FLAG feature flag. When the flag is
enabled for a course, the endpoint enforces the permission via
openedx-authz. When the flag is off, the existing legacy django-rules
checks are used.

Co-authored-by: Kiro <kiro-noreply@amazon.com>
@wgu-taylor-payne wgu-taylor-payne force-pushed the tpayne/authz-for-taxonomies branch from 93083cc to 55ae268 Compare April 10, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Task - RBAC Authz - Implement new permissions for Tags and Taxonomies

4 participants